<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Head -->
<head>
    <meta charset="utf-8"/>
    <title>${session.SOFT_NAME }_智能办公系统</title>
    <meta name="description" content="Dashboard"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <%include("/app/resapi/style.html"){}%>
    <script type="text/javascript" src="/gobal/js/jquery/jquery-2.0.3.min.js"></script>
    <script src="/module/fxofd/foxit.ofd.ocx.new.js"></script>
    <script type="text/javascript">
        var openModeType = "${parameter.openModeType}";
        var serverUrl = "${mServerUrl}"; //服务器地址
        var fileUrl = serverUrl + "/sys/file/openFileOnLine?attachId=${parameter.attachId}";
        var uploadPath = serverUrl + "/office/ofdSave?sessionId=${sessionId}&attachId=${parameter.attachId}&fileId=${fileId}";

        function getSealData() {
            var returnArr;
            $.ajax({
                url: "/ret/documentget/getSealToSignList",
                type: "post",
                dataType: "json",
                async: false,
                data: {
                    sessionId: "${sessionId}"
                },
                success: function (data) {
                    if (data.status == "200") {
                        returnArr = data.list;
                    } else if (data.status == "100") {
                        layer.msg(data.msg)
                    } else {
                        console.log(data.msg)
                    }
                }
            })
            return returnArr;
        }


    </script>

</head>
<body onload="fx_init()">
<div class="col-lg-12 col-sm-12 col-xs-12" style="padding:0px;display: none;" id="optdiv">
    <a href="javascript:void(0);" class="btn btn-blue btn-sm" onclick="fx_saveFile()">${i18n('save')}</a>
    <a href="javascript:void(0);" class="btn btn-maroon btn-sm" onclick="fx_printInfo('fileTitle',0)">打印</a>
</div>
<div id="objectdiv" style="display: inline-block; float: left;"></div>
<form action="">
    <input type="hidden" name="attachId" id="attachId" value="${attach.attachId}">
</form>
</body>
<script type="text/javascript">
    var obj;
    var viewValue;
    var xmlparam = "";

    //初始化插件
    function fx_init() {
        var width = document.documentElement.clientWidth;
        var height = document.documentElement.clientHeight;
        obj = OFD.OCX.init("objectdiv", width, height);
        obj.ready(obj._id);
        if (!("ActiveXObject" in window)) {
            obj.jsCallbackFun_InitSetting();
            obj.jsCallbackFun_UpdateInfo();
        }
        fx_openFile()
    }

    function fx_openFile() {
        var openModel = true;
        if (openModeType == "4" || openModeType == "5") {
            openModel = false;
        }
        var res = obj.openFile(fileUrl, openModel);
        if (res) {
            if (!openModel) {
                $("#optdiv").show();
                obj.setCompositeVisible("saveas", true);
            } else {
                if (openModeType == "2") {
                    obj.setCompositeVisible("Print", true);
                } else if (openModeType == "3") {
                    obj.setCompositeVisible("saveas", true);
                    obj.setCompositeVisible("Print", true);
                }
                $("#optdiv").remove();
            }
            obj.setCompositeVisible("GoBack", true);
            obj.setCompositeVisible("GoForward", true);
            obj.setCompositeVisible("ActualSize", true);
            obj.setCompositeVisible("FitPage", true);
            obj.setCompositeVisible("FitHeight", true);
            obj.setCompositeVisible("FitWidth", true);
            obj.setCompositeVisible("FitVisible", true);
            obj.setCompositeVisible("ScaleIn", true);
            obj.setCompositeVisible("ScaleOut", true);
            obj.setCompositeVisible("RotateCW", true);
            obj.setCompositeVisible("RotateCCW", true);
        } else {
            alert("文档打开失败！");
        }
    }

    function fx_saveFile() {
        var res = obj.saveFile(uploadPath + "&st=" + Math.random());
        if (res) {
            alert("保存成功！");
        }
    }

    function fx_printInfo(title, color) {
        obj.printFile(title, color);
    }

    function fx_saveasFile() {
        obj.saveasFile();
    }

</script>
</html>
